package com.axt.dbaudit.bean.cfg;

import java.util.List;

import com.axt.dbaudit.base.MsgFuncExt;
import com.axt.dbaudit.model.ManualBackUpDB;
import com.axt.soa.bean.BaseFuncBean;
import com.axt.soa.msg.types.MsgParam;

public class ManualBackUpDBBean extends BaseFuncBean {
	/**
	 * 删除给定的已备份的文件
	 * 
	 * @param aFileNameList
	 * @return boolean
	 */
	public int DeleteFiles(String serverPath, String fileNameList) {
		prepare(serverPath);

		request.addParam(MsgParam.CSP_F_DAY, fileNameList);
		request.addParam(MsgParam.CSP_F_SYMBOL, "F");
		return execute(MsgFuncExt.FUNC_DELETE_FILES, CONN_T_TCP);
	}

	/**
	 * 获得备份进度信息 备份进度可能不准确，delphi代码里使用备份信息做判断， 当"备份已经完成"时，表示备份完成， 当为空时表示备份失败
	 * 
	 * @return ManualBackUpDB
	 */
	public List<ManualBackUpDB> queryBackUpProgress(String serverPath) {
		prepare(serverPath);

		return fetch(MsgFuncExt.FUNC_QUERY_BACKPROGRESS,
				"com.axt.dbaudit.model.ManualBackUpDB", "ManualBackUpDB",
				CONN_T_TCP);
	}

	/**
	 * 发送要备份的文件信息
	 * 
	 * @param aBackupto
	 *            备份到哪个磁盘
	 * @param aBackUpDays
	 *            备份哪天的数据
	 * @param aBackupPwd
	 *            备份文件的密码，离线查询时需要使用这个密码
	 * @return boolean
	 */
	public int BeginBackUpDB(String serverPath,String backupto, String backUpDays,
			String backupPwd) {
		prepare(serverPath);
		
		
		request.addParam(MsgParam.CSP_F_BACKUPTO, backupto);
		request.addParam(MsgParam.CSP_F_BACKUPDAY, backUpDays);
		request.addParam(MsgParam.CSP_F_BACKUP_PWD, backupPwd);
		return execute(MsgFuncExt.FUNC_BEGIN_BACKUP_DATA, CONN_T_TCP);
	}

	/**
	 * 获得可以备份的文件，及可以备份到哪个磁盘的信息
	 * 
	 * @return
	 */
	public List<ManualBackUpDB> queryBackUpInfos(String serverPath) {
		prepare(serverPath);
		
		return fetch(
				MsgFuncExt.FUNC_QUERY_BACKUP_DATA,
				"com.axt.dbaudit.model.ManualBackUpDB", "ManualBackUpDB",
				CONN_T_TCP);
	}
}
